<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:conv="clr-namespace:QuickZip.Converters"            
    xmlns:local="clr-namespace:QuickZip.UserControls" 
    xmlns:pBarTest="clr-namespace:ProgressBarTest"
    xmlns:sys="clr-namespace:System;assembly=mscorlib" 
    >
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/QuickZip.UserControls;component/Themes/Geometry.xaml" />
        <ResourceDictionary Source="pack://application:,,,/QuickZip.UserControls;component/Themes/Brushes.xaml" />
        <ResourceDictionary Source="pack://application:,,,/QuickZip.UserControls;component/Themes/Templates.xaml" />
        <ResourceDictionary Source="pack://application:,,,/QuickZip.UserControls;component/Themes/Styles/StaticProgressBarStyle.xaml" />
        <ResourceDictionary Source="pack://application:,,,/QuickZip.UserControls;component/UserControls/ThirdParty/CircularProgressBar2/CircleProgressBarDictionary.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="{x:Type local:NotificationBarSubItem}"                       
           TargetType="{x:Type local:NotificationBarSubItem}" >

        <!--<Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:NotificationBarSubItem}">
                    
                </ControlTemplate>
            </Setter.Value>
        </Setter>-->

    </Style>

        <Style x:Key="{x:Type local:NotificationBarItem}"                       
           TargetType="{x:Type local:NotificationBarItem}">
        <Setter Property="HorizontalAlignment" Value="Left"  />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:NotificationBarItem}">
                    <Border x:Name="border" Margin="2,0" BorderBrush="{StaticResource LightBorderBrush}"                             
                            BorderThickness="1" Padding="2,0" CornerRadius="5"
                                Background="{StaticResource LightBrush}" >
                        <Grid x:Name="baseGrid" Width="175" Height="35">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="15" />
                            </Grid.ColumnDefinitions>             
                            <Grid Grid.Column="0" Margin="2" >
                                <Viewbox x:Name="pBarViewBox" Stretch="UniformToFill" Margin="2">
                                    <pBarTest:CircularProgressBar x:Name="pBar" Width="150" Height="150" Foreground="{TemplateBinding ProgressForeground}"
                                            Value="{TemplateBinding Progress}"
                                            Maximum="100"
                                            Style="{StaticResource CircleProgressBarStyle}" />
                                </Viewbox>
                                <Image x:Name="icon" Source="{TemplateBinding Icon}" Margin="8" Stretch="Fill" Opacity="1" />                                
                            </Grid>
                            
                            <StackPanel Grid.Column="1" Margin="2" >
                                <TextBlock x:Name="tbox" Text="{TemplateBinding Header}"                                            
                                           TextAlignment="Left" Margin="5,0,0,0" Foreground="{StaticResource NormalTextBrush}" />
                                <TextBlock x:Name="tbox2" Text="{TemplateBinding SubHeader}" TextAlignment="Left"  Foreground="{StaticResource GrayedTextBrush}" />
                            </StackPanel>

                            <ToggleButton Grid.Column="2" x:Name="buttonExpand" 
                                           IsChecked="{Binding Path=IsSubmenuOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" 
                                          Visibility="{Binding Path=HasItems,Mode=OneWay,RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource btv}}"
                                          Template="{StaticResource BasicArrowButton}" >
                                <ToggleButton.ToolTip>
                                    <ToolTip Background="Transparent" BorderBrush="Transparent" HasDropShadow="False" />
                                </ToggleButton.ToolTip>
                            </ToggleButton>
                            
                            <Popup  Name="Popup" IsOpen="{TemplateBinding IsSubmenuOpen}" 
                               Placement="Bottom"    PlacementTarget="{Binding ElementName=buttonExpand}"                                       
                                       PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"                                               
                                       AllowsTransparency="True" Margin="1,1,1,1"  Grid.ColumnSpan="2">
                                <Border BorderThickness="1,1,1,1" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" 
                                            Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" Name="DropDownBorder">

                                    <!--<Grid>
                                      
                                        <ScrollViewer CanContentScroll="True"  HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto"
                                                      Visibility="{Binding Path=IsLoading, Converter={StaticResource fbtvc},
                                                                  Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                                      >
                                            <ItemsPresenter x:Name="itemList" HorizontalAlignment="Stretch" VerticalAlignment="Center" 
                                                     SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"                                                      
                                                     MaxHeight="200" 
                                                     KeyboardNavigation.DirectionalNavigation="None"
                                                     VirtualizingStackPanel.IsVirtualizing="True" 
                                                     VirtualizingStackPanel.VirtualizationMode="Standard"                                                     
                                                    >
                                            </ItemsPresenter>
                                        </ScrollViewer>                                       
                                    </Grid>-->
                                    <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
                                </Border>
                            </Popup>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsActive" Value="False">
                            <Setter TargetName="tbox" Property="Foreground" Value="{StaticResource GrayedTextBrush}" />
                            <Setter TargetName="buttonExpand" Property="Foreground" Value="{StaticResource GrayedTextBrush}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="border" Property="Background" Value="{StaticResource HotTrackBrush}" />                                                     
                            <Setter Property="IsActive" Value="True" />
                        </Trigger>                            
                        
                        <EventTrigger RoutedEvent="{x:Static local:NotificationBarItem.FadeEvent}">
                            <BeginStoryboard>
                                <Storyboard >
                                    <DoubleAnimation To="0.5" Duration="0:0:0.5" Storyboard.TargetName="icon" Storyboard.TargetProperty="Opacity" />
                                    <DoubleAnimation To="0" Duration="0:0:0.5" Storyboard.TargetName="pBarViewBox" Storyboard.TargetProperty="Opacity" />
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="{x:Static local:NotificationBarItem.UnFadeEvent}">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation To="1" Duration="0:0:0.5" Storyboard.TargetName="icon" Storyboard.TargetProperty="Opacity" />
                                    <DoubleAnimation To="1" Duration="0:0:0.5" Storyboard.TargetName="pBarViewBox" Storyboard.TargetProperty="Opacity" />
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
